package us.gaaoc.framework.util;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class for Servlet: ImageServlet
 *
 */

 public class ImageServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
   static final long serialVersionUID = 1L;
     protected void doGet(HttpServletRequest request, HttpServletResponse response) 
	  throws ServletException, IOException{
	   
			try {
				// Get image file.
				String file = request.getParameter("file");
				String path="";
				BufferedInputStream in = new BufferedInputStream(new FileInputStream(path + file));
	 
				// Get image contents.
				byte[] bytes = new byte[in.available()];
				in.read(bytes);
				in.close();
	 
				// Write image contents to response.
				response.getOutputStream().write(bytes);
			} 
			catch (IOException e) {
				e.printStackTrace();
			}
    }
  	    
  }